package com.merry.mq.exchange.direct;

import com.merry.mq.utils.RabbitMQUtils;
import com.merry.mq.utils.SleepUtils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class DirectLogs {

    public static String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMQUtils.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME,"direct");

        int i=0;
        while (true){
            SleepUtils.sleep(1);
            if(i%3==0){
                String message = "hello,error"+i++;
                channel.basicPublish(EXCHANGE_NAME,"error",null,message.getBytes());
            }else{
                String message = "hello,info"+i++;
                channel.basicPublish(EXCHANGE_NAME,"info",null,message.getBytes());
            }
        }
    }
}
